Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Experiment: simplify internal representation notation |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | intrep-simpl |
Files: | files | file ages | folders |
SHA3-256: |
bf304129948c281a7a33ceeb2b93c3ad |
User & Date: | jan.nijtmans 2024-12-01 23:01:30.387 |
Context
2024-12-02
| ||
07:11 | Actual counter-proposal to TIP #707 check-in: 904cd27d0e user: jan.nijtmans tags: tip-707-alt | |
2024-12-01
| ||
23:01 | Experiment: simplify internal representation notation Closed-Leaf check-in: bf30412994 user: jan.nijtmans tags: intrep-simpl | |
17:42 | Fix compiler-warnings when TCL_COMPILE_DEBUG=1 check-in: b688a485b2 user: jan.nijtmans tags: trunk, main | |
Changes
Changes to generic/tcl.h.
︙ | ︙ | |||
711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 | * The following structure stores an internal representation (internalrep) for * a Tcl value. An internalrep is associated with an Tcl_ObjType when both * are stored in the same Tcl_Obj. The routines of the Tcl_ObjType govern * the handling of the internalrep. */ typedef union Tcl_ObjInternalRep { /* The internal representation: */ long longValue; /* - an long integer value. */ double doubleValue; /* - a double-precision floating value. */ void *otherValuePtr; /* - another, type-specific value, */ /* not used internally any more. */ Tcl_WideInt wideValue; /* - an integer value >= 64bits */ struct { /* - internal rep as two pointers. */ void *ptr1; void *ptr2; } twoPtrValue; struct { /* - internal rep as a pointer and a long, */ void *ptr; /* not used internally any more. */ unsigned long value; } ptrAndLongRep; } Tcl_ObjInternalRep; /* * One of the following structures exists for each object in the Tcl system. * An object stores a value as either a string, some internal representation, * or both. */ | > > > > > > > > > > > > > > | 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 | * The following structure stores an internal representation (internalrep) for * a Tcl value. An internalrep is associated with an Tcl_ObjType when both * are stored in the same Tcl_Obj. The routines of the Tcl_ObjType govern * the handling of the internalrep. */ typedef union Tcl_ObjInternalRep { /* The internal representation: */ #ifndef TCL_NO_DEPRECATED long longValue; /* - an long integer value. */ #endif double doubleValue; /* - a double-precision floating value. */ #ifndef TCL_NO_DEPRECATED void *otherValuePtr; /* - another, type-specific value, */ /* not used internally any more. */ #endif Tcl_WideInt wideValue; /* - an integer value >= 64bits */ struct { /* - internal rep as two pointers. */ void *ptr1; void *ptr2; } twoPtrValue; #ifndef TCL_NO_DEPRECATED struct { /* - internal rep as a pointer and a long, */ void *ptr; /* not used internally any more. */ unsigned long value; } ptrAndLongRep; #endif struct { void *ptr; void *ptr2; }; struct { Tcl_Size size; Tcl_Size size2; }; } Tcl_ObjInternalRep; /* * One of the following structures exists for each object in the Tcl system. * An object stores a value as either a string, some internal representation, * or both. */ |
︙ | ︙ |
Changes to generic/tclArithSeries.c.
︙ | ︙ | |||
186 187 188 189 190 191 192 | static inline ArithSeries * ArithSeriesGetInternalRep( Tcl_Obj *objPtr) { const Tcl_ObjInternalRep *irPtr = TclFetchInternalRep(objPtr, &arithSeriesType); | | | 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 | static inline ArithSeries * ArithSeriesGetInternalRep( Tcl_Obj *objPtr) { const Tcl_ObjInternalRep *irPtr = TclFetchInternalRep(objPtr, &arithSeriesType); return irPtr ? (ArithSeries *) irPtr->ptr : NULL; } /* * Compute number of significant fractional digits */ static inline unsigned Precision( |
︙ | ︙ | |||
302 303 304 305 306 307 308 | static void DupArithSeriesInternalRep( Tcl_Obj *srcPtr, /* Object with internal rep to copy. */ Tcl_Obj *copyPtr) /* Object with internal rep to set. */ { ArithSeries *srcRepPtr = (ArithSeries *) | | | | | | 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 | static void DupArithSeriesInternalRep( Tcl_Obj *srcPtr, /* Object with internal rep to copy. */ Tcl_Obj *copyPtr) /* Object with internal rep to set. */ { ArithSeries *srcRepPtr = (ArithSeries *) srcPtr->internalRep.ptr; if (srcRepPtr->isDouble) { ArithSeriesDbl *srcDblPtr = (ArithSeriesDbl *) srcRepPtr; ArithSeriesDbl *copyDblPtr = (ArithSeriesDbl *) Tcl_Alloc(sizeof(ArithSeriesDbl)); *copyDblPtr = *srcDblPtr; copyDblPtr->base.elements = NULL; copyPtr->internalRep.ptr = copyDblPtr; } else { ArithSeriesInt *srcIntPtr = (ArithSeriesInt *) srcRepPtr; ArithSeriesInt *copyIntPtr = (ArithSeriesInt *) Tcl_Alloc(sizeof(ArithSeriesInt)); *copyIntPtr = *srcIntPtr; copyIntPtr->base.elements = NULL; copyPtr->internalRep.ptr = copyIntPtr; } copyPtr->internalRep.ptr2 = NULL; copyPtr->typePtr = &arithSeriesType; } /* *---------------------------------------------------------------------- * * FreeArithSeriesInternalRep -- |
︙ | ︙ | |||
360 361 362 363 364 365 366 | } static void FreeArithSeriesInternalRep( Tcl_Obj *arithSeriesObjPtr) { ArithSeries *arithSeriesRepPtr = (ArithSeries *) | | | 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 | } static void FreeArithSeriesInternalRep( Tcl_Obj *arithSeriesObjPtr) { ArithSeries *arithSeriesRepPtr = (ArithSeries *) arithSeriesObjPtr->internalRep.ptr; if (arithSeriesRepPtr) { FreeElements(arithSeriesRepPtr); Tcl_Free((char *) arithSeriesRepPtr); } } |
︙ | ︙ | |||
414 415 416 417 418 419 420 | arithSeriesRepPtr = (ArithSeriesInt *) Tcl_Alloc(sizeof(ArithSeriesInt)); arithSeriesRepPtr->base.len = length; arithSeriesRepPtr->base.elements = NULL; arithSeriesRepPtr->base.isDouble = 0; arithSeriesRepPtr->start = start; arithSeriesRepPtr->end = end; arithSeriesRepPtr->step = step; | | | | 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 | arithSeriesRepPtr = (ArithSeriesInt *) Tcl_Alloc(sizeof(ArithSeriesInt)); arithSeriesRepPtr->base.len = length; arithSeriesRepPtr->base.elements = NULL; arithSeriesRepPtr->base.isDouble = 0; arithSeriesRepPtr->start = start; arithSeriesRepPtr->end = end; arithSeriesRepPtr->step = step; arithSeriesObj->internalRep.ptr = arithSeriesRepPtr; arithSeriesObj->internalRep.ptr2 = NULL; arithSeriesObj->typePtr = &arithSeriesType; if (length > 0) { Tcl_InvalidateStringRep(arithSeriesObj); } return arithSeriesObj; } |
︙ | ︙ | |||
470 471 472 473 474 475 476 | arithSeriesRepPtr->base.len = length; arithSeriesRepPtr->base.elements = NULL; arithSeriesRepPtr->base.isDouble = 1; arithSeriesRepPtr->start = start; arithSeriesRepPtr->end = end; arithSeriesRepPtr->step = step; arithSeriesRepPtr->precision = maxPrecision(start, end, step); | | | | 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 | arithSeriesRepPtr->base.len = length; arithSeriesRepPtr->base.elements = NULL; arithSeriesRepPtr->base.isDouble = 1; arithSeriesRepPtr->start = start; arithSeriesRepPtr->end = end; arithSeriesRepPtr->step = step; arithSeriesRepPtr->precision = maxPrecision(start, end, step); arithSeriesObj->internalRep.ptr = arithSeriesRepPtr; arithSeriesObj->internalRep.ptr2 = NULL; arithSeriesObj->typePtr = &arithSeriesType; if (length > 0) { Tcl_InvalidateStringRep(arithSeriesObj); } return arithSeriesObj; |
︙ | ︙ | |||
711 712 713 714 715 716 717 | *---------------------------------------------------------------------- */ Tcl_Size ArithSeriesObjLength( Tcl_Obj *arithSeriesObj) { ArithSeries *arithSeriesRepPtr = (ArithSeries *) | | | 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 | *---------------------------------------------------------------------- */ Tcl_Size ArithSeriesObjLength( Tcl_Obj *arithSeriesObj) { ArithSeries *arithSeriesRepPtr = (ArithSeries *) arithSeriesObj->internalRep.ptr; return arithSeriesRepPtr->len; } /* *---------------------------------------------------------------------- * * TclArithSeriesObjStep -- |
︙ | ︙ | |||
1118 1119 1120 1121 1122 1123 1124 | *---------------------------------------------------------------------- */ static void UpdateStringOfArithSeries( Tcl_Obj *arithSeriesObjPtr) { ArithSeries *arithSeriesRepPtr = (ArithSeries *) | | | 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 | *---------------------------------------------------------------------- */ static void UpdateStringOfArithSeries( Tcl_Obj *arithSeriesObjPtr) { ArithSeries *arithSeriesRepPtr = (ArithSeries *) arithSeriesObjPtr->internalRep.ptr; char *p; Tcl_Obj *eleObj; Tcl_Size i, bytlen = 0; /* * Pass 1: estimate space. */ |
︙ | ︙ | |||
1197 1198 1199 1200 1201 1202 1203 | ArithSeriesInOperation( Tcl_Interp *interp, Tcl_Obj *valueObj, Tcl_Obj *arithSeriesObjPtr, int *boolResult) { ArithSeries *repPtr = (ArithSeries *) | | | 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 | ArithSeriesInOperation( Tcl_Interp *interp, Tcl_Obj *valueObj, Tcl_Obj *arithSeriesObjPtr, int *boolResult) { ArithSeries *repPtr = (ArithSeries *) arithSeriesObjPtr->internalRep.ptr; int status; Tcl_Size index, incr, elen, vlen; if (repPtr->isDouble) { ArithSeriesDbl *dblRepPtr = (ArithSeriesDbl *) repPtr; double y; int test = 0; |
︙ | ︙ |
Changes to generic/tclBinary.c.
︙ | ︙ | |||
184 185 186 187 188 189 190 | } ByteArray; #define BYTEARRAY_MAX_LEN (TCL_SIZE_MAX - (Tcl_Size)offsetof(ByteArray, bytes)) #define BYTEARRAY_SIZE(len) \ ( (len < 0 || BYTEARRAY_MAX_LEN < (len)) \ ? (Tcl_Panic("negative length specified or max size of a Tcl value exceeded"), 0) \ : (offsetof(ByteArray, bytes) + (len)) ) | | | | 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 | } ByteArray; #define BYTEARRAY_MAX_LEN (TCL_SIZE_MAX - (Tcl_Size)offsetof(ByteArray, bytes)) #define BYTEARRAY_SIZE(len) \ ( (len < 0 || BYTEARRAY_MAX_LEN < (len)) \ ? (Tcl_Panic("negative length specified or max size of a Tcl value exceeded"), 0) \ : (offsetof(ByteArray, bytes) + (len)) ) #define GET_BYTEARRAY(irPtr) ((ByteArray *) (irPtr)->ptr) #define SET_BYTEARRAY(irPtr, baPtr) \ (irPtr)->ptr = (baPtr) int TclIsPureByteArray( Tcl_Obj * objPtr) { return TclHasInternalRep(objPtr, &properByteArrayType); } |
︙ | ︙ |
Changes to generic/tclClockFmt.c.
︙ | ︙ | |||
645 646 647 648 649 650 651 | ClockFmtObj_DupInternalRep, /* dupIntRepProc */ ClockFmtObj_UpdateString, /* updateStringProc */ ClockFmtObj_SetFromAny, /* setFromAnyProc */ TCL_OBJTYPE_V0 }; #define ObjClockFmtScn(objPtr) \ | | | | 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 | ClockFmtObj_DupInternalRep, /* dupIntRepProc */ ClockFmtObj_UpdateString, /* updateStringProc */ ClockFmtObj_SetFromAny, /* setFromAnyProc */ TCL_OBJTYPE_V0 }; #define ObjClockFmtScn(objPtr) \ (*((ClockFmtScnStorage **)&(objPtr)->internalRep.ptr)) #define ObjLocFmtKey(objPtr) \ (*((Tcl_Obj **)&(objPtr)->internalRep.ptr2)) static void ClockFmtObj_DupInternalRep( Tcl_Obj *srcPtr, Tcl_Obj *copyPtr) { ClockFmtScnStorage *fss = ObjClockFmtScn(srcPtr); |
︙ | ︙ |
Changes to generic/tclCompile.c.
︙ | ︙ | |||
736 737 738 739 740 741 742 | "substcode", /* name */ FreeSubstCodeInternalRep, /* freeIntRepProc */ DupByteCodeInternalRep, /* dupIntRepProc - shared with bytecode */ NULL, /* updateStringProc */ NULL, /* setFromAnyProc */ TCL_OBJTYPE_V0 }; | | | 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 | "substcode", /* name */ FreeSubstCodeInternalRep, /* freeIntRepProc */ DupByteCodeInternalRep, /* dupIntRepProc - shared with bytecode */ NULL, /* updateStringProc */ NULL, /* setFromAnyProc */ TCL_OBJTYPE_V0 }; #define SubstFlags(objPtr) (objPtr)->internalRep.ptr2 /* * Helper macros. */ #define TclIncrUInt4AtPtr(ptr, delta) \ TclStoreInt4AtPtr(TclGetUInt4AtPtr(ptr)+(delta), (ptr)) |
︙ | ︙ |
Changes to generic/tclCompile.h.
︙ | ︙ | |||
528 529 530 531 532 533 534 | * created. */ #endif /* TCL_COMPILE_STATS */ } ByteCode; #define ByteCodeSetInternalRep(objPtr, typePtr, codePtr) \ do { \ Tcl_ObjInternalRep ir; \ | | | | | 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 | * created. */ #endif /* TCL_COMPILE_STATS */ } ByteCode; #define ByteCodeSetInternalRep(objPtr, typePtr, codePtr) \ do { \ Tcl_ObjInternalRep ir; \ ir.ptr = (codePtr); \ ir.ptr2 = NULL; \ Tcl_StoreInternalRep((objPtr), (typePtr), &ir); \ } while (0) #define ByteCodeGetInternalRep(objPtr, typePtr, codePtr) \ do { \ const Tcl_ObjInternalRep *irPtr; \ irPtr = TclFetchInternalRep((objPtr), (typePtr)); \ (codePtr) = irPtr ? (ByteCode*)irPtr->ptr : NULL; \ } while (0) /* * Opcodes for the Tcl bytecode instructions. These must correspond to the * entries in the table of instruction descriptions, tclInstructionTable, in * tclCompile.c. Also, the order and number of the expression opcodes (e.g., * INST_BITOR) must match the entries in the array operatorStrings in |
︙ | ︙ |
Changes to generic/tclDictObj.c.
︙ | ︙ | |||
149 150 151 152 153 154 155 | SetDictFromAny, /* setFromAnyProc */ TCL_OBJTYPE_V0 }; #define DictSetInternalRep(objPtr, dictRepPtr) \ do { \ Tcl_ObjInternalRep ir; \ | | | | | 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 | SetDictFromAny, /* setFromAnyProc */ TCL_OBJTYPE_V0 }; #define DictSetInternalRep(objPtr, dictRepPtr) \ do { \ Tcl_ObjInternalRep ir; \ ir.ptr = (dictRepPtr); \ ir.ptr2 = NULL; \ Tcl_StoreInternalRep((objPtr), &tclDictType, &ir); \ } while (0) #define DictGetInternalRep(objPtr, dictRepPtr) \ do { \ const Tcl_ObjInternalRep *irPtr; \ irPtr = TclFetchInternalRep((objPtr), &tclDictType); \ (dictRepPtr) = irPtr ? (Dict *)irPtr->ptr : NULL; \ } while (0) /* * The type of the specially adapted version of the Tcl_Obj*-containing hash * table defined in the tclObj.c code. This version differs in that it * allocates a bit more space in each hash entry in order to hold the pointers * used to keep the hash entries in a linked list. |
︙ | ︙ | |||
2250 2251 2252 2253 2254 2255 2256 | } DictGetInternalRep(dictPtr, dict); result = Tcl_NewObj(); DictSetInternalRep(result, dict); dict->refCount++; | | | 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 | } DictGetInternalRep(dictPtr, dict); result = Tcl_NewObj(); DictSetInternalRep(result, dict); dict->refCount++; result->internalRep.ptr2 = NULL; result->typePtr = &tclDictType; return result; } /* *---------------------------------------------------------------------- |
︙ | ︙ |
Changes to generic/tclEncoding.c.
︙ | ︙ | |||
256 257 258 259 260 261 262 | static Tcl_EncodingConvertProc UtfToUtf16Proc; static Tcl_EncodingConvertProc UtfToUcs2Proc; static Tcl_EncodingConvertProc UtfToUtfProc; static Tcl_EncodingConvertProc Iso88591FromUtfProc; static Tcl_EncodingConvertProc Iso88591ToUtfProc; /* | | | | | | 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 | static Tcl_EncodingConvertProc UtfToUtf16Proc; static Tcl_EncodingConvertProc UtfToUcs2Proc; static Tcl_EncodingConvertProc UtfToUtfProc; static Tcl_EncodingConvertProc Iso88591FromUtfProc; static Tcl_EncodingConvertProc Iso88591ToUtfProc; /* * A Tcl_ObjType for holding a cached Tcl_Encoding in the ptr * field of the internalrep. This should help the lifetime of encodings be more * useful. See concerns raised in [Bug 1077262]. */ static const Tcl_ObjType encodingType = { "encoding", FreeEncodingInternalRep, DupEncodingInternalRep, NULL, NULL, TCL_OBJTYPE_V0 }; #define EncodingSetInternalRep(objPtr, encoding) \ do { \ Tcl_ObjInternalRep ir; \ ir.ptr = (encoding); \ ir.ptr2 = NULL; \ Tcl_StoreInternalRep((objPtr), &encodingType, &ir); \ } while (0) #define EncodingGetInternalRep(objPtr, encoding) \ do { \ const Tcl_ObjInternalRep *irPtr; \ irPtr = TclFetchInternalRep ((objPtr), &encodingType); \ (encoding) = irPtr ? (Tcl_Encoding)irPtr->ptr : NULL; \ } while (0) /* *---------------------------------------------------------------------- * * Tcl_GetEncodingFromObj -- * |
︙ | ︙ |
Changes to generic/tclEnsemble.c.
︙ | ︙ | |||
92 93 94 95 96 97 98 | NULL, /* setFromAnyProc */ TCL_OBJTYPE_V0 }; #define ECRSetInternalRep(objPtr, ecRepPtr) \ do { \ Tcl_ObjInternalRep ir; \ | | | | | 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 | NULL, /* setFromAnyProc */ TCL_OBJTYPE_V0 }; #define ECRSetInternalRep(objPtr, ecRepPtr) \ do { \ Tcl_ObjInternalRep ir; \ ir.ptr = (ecRepPtr); \ ir.ptr2 = NULL; \ Tcl_StoreInternalRep((objPtr), &ensembleCmdType, &ir); \ } while (0) #define ECRGetInternalRep(objPtr, ecRepPtr) \ do { \ const Tcl_ObjInternalRep *irPtr; \ irPtr = TclFetchInternalRep((objPtr), &ensembleCmdType); \ (ecRepPtr) = irPtr ? (EnsembleCmdRep *) \ irPtr->ptr : NULL; \ } while (0) /* * The internal rep for caching ensemble subcommand lookups and spelling * corrections. */ |
︙ | ︙ |
Changes to generic/tclExecute.c.
︙ | ︙ | |||
132 133 134 135 136 137 138 | } while (0) #define PUSH_TAUX_OBJ(objPtr) \ do { \ if (auxObjList) { \ (objPtr)->length += auxObjList->length; \ } \ | | | | 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 | } while (0) #define PUSH_TAUX_OBJ(objPtr) \ do { \ if (auxObjList) { \ (objPtr)->length += auxObjList->length; \ } \ (objPtr)->internalRep.ptr = auxObjList; \ auxObjList = (objPtr); \ } while (0) #define POP_TAUX_OBJ() \ do { \ tmpPtr = auxObjList; \ auxObjList = (Tcl_Obj *)tmpPtr->internalRep.ptr; \ Tcl_DecrRefCount(tmpPtr); \ } while (0) /* * These variable-access macros have to coincide with those in tclVar.c */ |
︙ | ︙ | |||
709 710 711 712 713 714 715 | assert(irPtr != NULL); /* * First kill the search, and then release the reference to the dictionary * that we were holding. */ | | | | 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 | assert(irPtr != NULL); /* * First kill the search, and then release the reference to the dictionary * that we were holding. */ searchPtr = (Tcl_DictSearch *)irPtr->ptr; Tcl_DictObjDone(searchPtr); Tcl_Free(searchPtr); dictPtr = (Tcl_Obj *)irPtr->ptr2; TclDecrRefCount(dictPtr); } /* *---------------------------------------------------------------------- * * InitByteCodeExecution -- |
︙ | ︙ | |||
2632 2633 2634 2635 2636 2637 2638 | * we do not define a special tclObjType for it. It is not dangerous * as the obj is never passed anywhere, so that all manipulations are * performed here and in INST_INVOKE_EXPANDED (in case of an expansion * error, also in INST_EXPAND_STKTOP). */ TclNewObj(objPtr); | | | | 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 | * we do not define a special tclObjType for it. It is not dangerous * as the obj is never passed anywhere, so that all manipulations are * performed here and in INST_INVOKE_EXPANDED (in case of an expansion * error, also in INST_EXPAND_STKTOP). */ TclNewObj(objPtr); objPtr->internalRep.size2 = CURR_DEPTH; objPtr->length = 0; PUSH_TAUX_OBJ(objPtr); TRACE(("=> mark depth as %" TCL_T_MODIFIER "d\n", CURR_DEPTH)); NEXT_INST_F(1, 0, 0); break; case INST_EXPAND_DROP: /* * Drops an element of the auxObjList, popping stack elements to * restore the stack to the state before the point where the aux * element was created. */ CLANG_ASSERT(auxObjList); objc = CURR_DEPTH - auxObjList->internalRep.size2; POP_TAUX_OBJ(); #ifdef TCL_COMPILE_DEBUG /* Ugly abuse! */ starting = 1; #endif TRACE(("=> drop %" TCL_SIZE_MODIFIER "d items\n", objc)); NEXT_INST_V(1, objc, 0); |
︙ | ︙ | |||
2754 2755 2756 2757 2758 2759 2760 | TEBC_YIELD(); /* add TEBCResume for object at top of stack */ return TclNRExecuteByteCode(interp, TclCompileObj(interp, OBJ_AT_TOS, NULL, 0)); case INST_INVOKE_EXPANDED: CLANG_ASSERT(auxObjList); | | | 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 | TEBC_YIELD(); /* add TEBCResume for object at top of stack */ return TclNRExecuteByteCode(interp, TclCompileObj(interp, OBJ_AT_TOS, NULL, 0)); case INST_INVOKE_EXPANDED: CLANG_ASSERT(auxObjList); objc = CURR_DEPTH - auxObjList->internalRep.size2; POP_TAUX_OBJ(); if (objc) { pcAdjustment = 1; goto doInvocation; } /* |
︙ | ︙ | |||
6511 6512 6513 6514 6515 6516 6517 | * Store the iterNum and iterMax in a single Tcl_Obj; we keep a * nul-string obj with the pointer stored in the ptrValue so that the * thing is properly garbage collected. THIS OBJ MAKES NO SENSE, but * it will never leave this scope and is read-only. */ TclNewObj(tmpPtr); | | | | | | | | | 6511 6512 6513 6514 6515 6516 6517 6518 6519 6520 6521 6522 6523 6524 6525 6526 6527 6528 6529 6530 6531 6532 6533 6534 6535 6536 6537 6538 6539 6540 6541 6542 6543 6544 6545 6546 6547 6548 6549 6550 6551 6552 6553 6554 6555 6556 6557 6558 6559 6560 6561 6562 6563 6564 6565 6566 6567 6568 6569 6570 6571 6572 | * Store the iterNum and iterMax in a single Tcl_Obj; we keep a * nul-string obj with the pointer stored in the ptrValue so that the * thing is properly garbage collected. THIS OBJ MAKES NO SENSE, but * it will never leave this scope and is read-only. */ TclNewObj(tmpPtr); tmpPtr->internalRep.ptr = NULL; tmpPtr->internalRep.ptr2 = (void *)iterMax; PUSH_OBJECT(tmpPtr); /* iterCounts object */ /* * Store a pointer to the ForeachInfo struct; same dirty trick * as above */ TclNewObj(tmpPtr); tmpPtr->internalRep.ptr = infoPtr; PUSH_OBJECT(tmpPtr); /* infoPtr object */ TRACE_APPEND(("jump to loop step\n")); /* * Jump directly to the INST_FOREACH_STEP instruction; the C code just * falls through. */ pc += 5 - infoPtr->loopCtTemp; case INST_FOREACH_STEP: /* TODO: address abstract list indexing here! */ /* * "Step" a foreach loop (i.e., begin its next iteration) by assigning * the next value list element to each loop var. */ tmpPtr = OBJ_AT_TOS; infoPtr = (ForeachInfo *)tmpPtr->internalRep.ptr; numLists = infoPtr->numLists; TRACE(("=> ")); tmpPtr = OBJ_AT_DEPTH(1); iterNum = (size_t)tmpPtr->internalRep.ptr; iterMax = (size_t)tmpPtr->internalRep.ptr2; /* * If some list still has a remaining list element iterate one more * time. Assign to var the next element from its value list. */ if (iterNum < iterMax) { int status; /* * Set the variables and jump back to run the body */ tmpPtr->internalRep.ptr =(void *)(iterNum + 1); listTmpDepth = numLists + 1; for (i = 0; i < numLists; i++) { varListPtr = infoPtr->varLists[i]; numVars = varListPtr->numVars; int hasAbstractList; |
︙ | ︙ | |||
6654 6655 6656 6657 6658 6659 6660 | */ pc++; #endif case INST_FOREACH_END: /* THIS INSTRUCTION IS ONLY CALLED AS A BREAK TARGET */ tmpPtr = OBJ_AT_TOS; | | | | 6654 6655 6656 6657 6658 6659 6660 6661 6662 6663 6664 6665 6666 6667 6668 6669 6670 6671 6672 6673 6674 6675 6676 6677 6678 6679 6680 6681 6682 6683 6684 6685 | */ pc++; #endif case INST_FOREACH_END: /* THIS INSTRUCTION IS ONLY CALLED AS A BREAK TARGET */ tmpPtr = OBJ_AT_TOS; infoPtr = (ForeachInfo *)tmpPtr->internalRep.ptr; numLists = infoPtr->numLists; TRACE(("=> loop terminated\n")); NEXT_INST_V(1, numLists+2, 0); case INST_LMAP_COLLECT: /* * This instruction is only issued by lmap. The stack is: * - result * - infoPtr * - loop counters * - valLists * - collecting obj (unshared) * The instruction lappends the result to the collecting obj. */ tmpPtr = OBJ_AT_DEPTH(1); infoPtr = (ForeachInfo *)tmpPtr->internalRep.ptr; numLists = infoPtr->numLists; TRACE_APPEND(("=> appending to list at depth %" TCL_SIZE_MODIFIER "d\n", 3 + numLists)); objPtr = OBJ_AT_DEPTH(3 + numLists); Tcl_ListObjAppendElement(NULL, objPtr, OBJ_AT_TOS); NEXT_INST_F(1, 1, 0); } |
︙ | ︙ | |||
7138 7139 7140 7141 7142 7143 7144 | Tcl_Free(searchPtr); TRACE_ERROR(interp); goto gotError; } { Tcl_ObjInternalRep ir; TclNewObj(statePtr); | | | | 7138 7139 7140 7141 7142 7143 7144 7145 7146 7147 7148 7149 7150 7151 7152 7153 | Tcl_Free(searchPtr); TRACE_ERROR(interp); goto gotError; } { Tcl_ObjInternalRep ir; TclNewObj(statePtr); ir.ptr = searchPtr; ir.ptr2 = dictPtr; Tcl_StoreInternalRep(statePtr, &dictIteratorType, &ir); } varPtr = LOCAL(opnd); if (varPtr->value.objPtr) { if (TclHasInternalRep(varPtr->value.objPtr, &dictIteratorType)) { Tcl_Panic("mis-issued dictFirst!"); } |
︙ | ︙ | |||
7162 7163 7164 7165 7166 7167 7168 | TRACE(("%u => ", opnd)); statePtr = (*LOCAL(opnd)).value.objPtr; { const Tcl_ObjInternalRep *irPtr; if (statePtr && (irPtr = TclFetchInternalRep(statePtr, &dictIteratorType))) { | | | 7162 7163 7164 7165 7166 7167 7168 7169 7170 7171 7172 7173 7174 7175 7176 | TRACE(("%u => ", opnd)); statePtr = (*LOCAL(opnd)).value.objPtr; { const Tcl_ObjInternalRep *irPtr; if (statePtr && (irPtr = TclFetchInternalRep(statePtr, &dictIteratorType))) { searchPtr = (Tcl_DictSearch *)irPtr->ptr; Tcl_DictObjNext(searchPtr, &keyPtr, &valuePtr, &done); } else { Tcl_Panic("mis-issued dictNext!"); } } pushDictIteratorResult: if (done) { |
︙ | ︙ | |||
7603 7604 7605 7606 7607 7608 7609 | * Clear all expansions that may have started after the last * INST_BEGIN_CATCH. */ while (auxObjList) { if ((catchTop != initCatchTop) && (PTR2INT(*catchTop) > | | | 7603 7604 7605 7606 7607 7608 7609 7610 7611 7612 7613 7614 7615 7616 7617 | * Clear all expansions that may have started after the last * INST_BEGIN_CATCH. */ while (auxObjList) { if ((catchTop != initCatchTop) && (PTR2INT(*catchTop) > auxObjList->internalRep.size2)) { break; } POP_TAUX_OBJ(); } /* * We must not catch if the script in progress has been canceled with |
︙ | ︙ |
Changes to generic/tclIO.c.
︙ | ︙ | |||
343 344 345 346 347 348 349 | TCL_OBJTYPE_V0 }; #define ChanSetInternalRep(objPtr, resPtr) \ do { \ Tcl_ObjInternalRep ir; \ (resPtr)->refCount++; \ | | | | | 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 | TCL_OBJTYPE_V0 }; #define ChanSetInternalRep(objPtr, resPtr) \ do { \ Tcl_ObjInternalRep ir; \ (resPtr)->refCount++; \ ir.ptr = (resPtr); \ ir.ptr2 = NULL; \ Tcl_StoreInternalRep((objPtr), &chanObjType, &ir); \ } while (0) #define ChanGetInternalRep(objPtr, resPtr) \ do { \ const Tcl_ObjInternalRep *irPtr; \ irPtr = TclFetchInternalRep((objPtr), &chanObjType); \ (resPtr) = irPtr ? (ResolvedChanName *)irPtr->ptr : NULL; \ } while (0) #define BUSY_STATE(st, fl) \ ((((st)->csPtrR) && ((fl) & TCL_READABLE)) || \ (((st)->csPtrW) && ((fl) & TCL_WRITABLE))) #define MAX_CHANNEL_BUFFER_SIZE (1024*1024) |
︙ | ︙ |
Changes to generic/tclIndexObj.c.
︙ | ︙ | |||
43 44 45 46 47 48 49 | UpdateStringOfIndex, /* updateStringProc */ NULL, /* setFromAnyProc */ TCL_OBJTYPE_V0 }; /* * The definition of the internal representation of the "index" object; The | | | 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 | UpdateStringOfIndex, /* updateStringProc */ NULL, /* setFromAnyProc */ TCL_OBJTYPE_V0 }; /* * The definition of the internal representation of the "index" object; The * internalRep.ptr field of an object of "index" type will be a * pointer to one of these structures. * * Keep this structure declaration in sync with tclTestObj.c */ typedef struct { void *tablePtr; /* Pointer to the table of strings */ |
︙ | ︙ | |||
212 213 214 215 216 217 218 | /* * See if there is a valid cached result from a previous lookup. */ if (objPtr && !(flags & TCL_INDEX_TEMP_TABLE)) { irPtr = TclFetchInternalRep(objPtr, &tclIndexType); if (irPtr) { | | | 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 | /* * See if there is a valid cached result from a previous lookup. */ if (objPtr && !(flags & TCL_INDEX_TEMP_TABLE)) { irPtr = TclFetchInternalRep(objPtr, &tclIndexType); if (irPtr) { indexRep = (IndexRep *)irPtr->ptr; if ((indexRep->tablePtr == tablePtr) && (indexRep->offset == offset) && (indexRep->index != TCL_INDEX_NONE)) { index = indexRep->index; goto uncachedDone; } } |
︙ | ︙ | |||
281 282 283 284 285 286 287 | * new internal-rep if at all possible since that is potentially a slow * operation. */ if (objPtr && (index != TCL_INDEX_NONE) && !(flags & TCL_INDEX_TEMP_TABLE)) { irPtr = TclFetchInternalRep(objPtr, &tclIndexType); if (irPtr) { | | | | 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 | * new internal-rep if at all possible since that is potentially a slow * operation. */ if (objPtr && (index != TCL_INDEX_NONE) && !(flags & TCL_INDEX_TEMP_TABLE)) { irPtr = TclFetchInternalRep(objPtr, &tclIndexType); if (irPtr) { indexRep = (IndexRep *)irPtr->ptr; } else { Tcl_ObjInternalRep ir; indexRep = (IndexRep*)Tcl_Alloc(sizeof(IndexRep)); ir.ptr = indexRep; Tcl_StoreInternalRep(objPtr, &tclIndexType, &ir); } indexRep->tablePtr = (void *) tablePtr; indexRep->offset = offset; indexRep->index = index; } |
︙ | ︙ | |||
382 383 384 385 386 387 388 | *---------------------------------------------------------------------- */ static void UpdateStringOfIndex( Tcl_Obj *objPtr) { | | | 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 | *---------------------------------------------------------------------- */ static void UpdateStringOfIndex( Tcl_Obj *objPtr) { IndexRep *indexRep = (IndexRep *)TclFetchInternalRep(objPtr, &tclIndexType)->ptr; const char *indexStr = EXPAND_OF(indexRep); Tcl_InitStringRep(objPtr, indexStr, strlen(indexStr)); } /* *---------------------------------------------------------------------- |
︙ | ︙ | |||
414 415 416 417 418 419 420 | DupIndex( Tcl_Obj *srcPtr, Tcl_Obj *dupPtr) { Tcl_ObjInternalRep ir; IndexRep *dupIndexRep = (IndexRep *)Tcl_Alloc(sizeof(IndexRep)); | | | | 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 | DupIndex( Tcl_Obj *srcPtr, Tcl_Obj *dupPtr) { Tcl_ObjInternalRep ir; IndexRep *dupIndexRep = (IndexRep *)Tcl_Alloc(sizeof(IndexRep)); memcpy(dupIndexRep, TclFetchInternalRep(srcPtr, &tclIndexType)->ptr, sizeof(IndexRep)); ir.ptr = dupIndexRep; Tcl_StoreInternalRep(dupPtr, &tclIndexType, &ir); } /* *---------------------------------------------------------------------- * * FreeIndex -- |
︙ | ︙ | |||
442 443 444 445 446 447 448 | *---------------------------------------------------------------------- */ static void FreeIndex( Tcl_Obj *objPtr) { | | | 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 | *---------------------------------------------------------------------- */ static void FreeIndex( Tcl_Obj *objPtr) { Tcl_Free(TclFetchInternalRep(objPtr, &tclIndexType)->ptr); objPtr->typePtr = NULL; } /* *---------------------------------------------------------------------- * * TclInitPrefixCmd -- |
︙ | ︙ | |||
863 864 865 866 867 868 869 | for (i=0 ; i<toPrint ; i++) { /* * Add the element, quoting it if necessary. */ const Tcl_ObjInternalRep *irPtr; if ((irPtr = TclFetchInternalRep(origObjv[i], &tclIndexType))) { | | | 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 | for (i=0 ; i<toPrint ; i++) { /* * Add the element, quoting it if necessary. */ const Tcl_ObjInternalRep *irPtr; if ((irPtr = TclFetchInternalRep(origObjv[i], &tclIndexType))) { IndexRep *indexRep = (IndexRep *)irPtr->ptr; elementStr = EXPAND_OF(indexRep); elemLen = strlen(elementStr); } else { elementStr = TclGetStringFromObj(origObjv[i], &elemLen); } flags = 0; |
︙ | ︙ | |||
910 911 912 913 914 915 916 | * If the object is an index type, use the index table which allows for * the correct error message even if the subcommand was abbreviated. * Otherwise, just use the string rep. */ const Tcl_ObjInternalRep *irPtr; if ((irPtr = TclFetchInternalRep(objv[i], &tclIndexType))) { | | | 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 | * If the object is an index type, use the index table which allows for * the correct error message even if the subcommand was abbreviated. * Otherwise, just use the string rep. */ const Tcl_ObjInternalRep *irPtr; if ((irPtr = TclFetchInternalRep(objv[i], &tclIndexType))) { IndexRep *indexRep = (IndexRep *)irPtr->ptr; Tcl_AppendStringsToObj(objPtr, EXPAND_OF(indexRep), (char *)NULL); } else { /* * Quote the argument if it contains spaces (Bug 942757). */ |
︙ | ︙ |
Changes to generic/tclInt.h.
︙ | ︙ | |||
2664 2665 2666 2667 2668 2669 2670 | ((objc_) = ListRepLength(listRepPtr_))) /* Returns 1/0 whether the ListRep's ListStore is shared. */ #define ListRepIsShared(listRepPtr_) ((listRepPtr_)->storePtr->refCount > 1) /* Returns a pointer to the ListStore component */ #define ListObjStorePtr(listObj_) \ | | | | 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 | ((objc_) = ListRepLength(listRepPtr_))) /* Returns 1/0 whether the ListRep's ListStore is shared. */ #define ListRepIsShared(listRepPtr_) ((listRepPtr_)->storePtr->refCount > 1) /* Returns a pointer to the ListStore component */ #define ListObjStorePtr(listObj_) \ ((ListStore *)((listObj_)->internalRep.ptr)) /* Returns a pointer to the ListSpan component */ #define ListObjSpanPtr(listObj_) \ ((ListSpan *)((listObj_)->internalRep.ptr2)) /* Returns the ListRep internal representaton in a Tcl_Obj */ #define ListObjGetRep(listObj_, listRepPtr_) \ do { \ (listRepPtr_)->storePtr = ListObjStorePtr(listObj_); \ (listRepPtr_)->spanPtr = ListObjSpanPtr(listObj_); \ } while (0) |
︙ | ︙ | |||
4325 4326 4327 4328 4329 4330 4331 | AllocCache *cachePtr; \ if (((interp) == NULL) || \ ((cachePtr = ((Interp *)(interp))->allocCache), \ (cachePtr->numObjects == 0))) { \ (objPtr) = TclThreadAllocObj(); \ } else { \ (objPtr) = cachePtr->firstObjPtr; \ | | | | 4325 4326 4327 4328 4329 4330 4331 4332 4333 4334 4335 4336 4337 4338 4339 4340 4341 4342 4343 4344 4345 4346 4347 4348 4349 4350 4351 4352 4353 | AllocCache *cachePtr; \ if (((interp) == NULL) || \ ((cachePtr = ((Interp *)(interp))->allocCache), \ (cachePtr->numObjects == 0))) { \ (objPtr) = TclThreadAllocObj(); \ } else { \ (objPtr) = cachePtr->firstObjPtr; \ cachePtr->firstObjPtr = (Tcl_Obj *)(objPtr)->internalRep.ptr; \ --cachePtr->numObjects; \ } \ } while (0) # define TclFreeObjStorageEx(interp, objPtr) \ do { \ AllocCache *cachePtr; \ if (((interp) == NULL) || \ ((cachePtr = ((Interp *)(interp))->allocCache), \ ((cachePtr->numObjects == 0) || \ (cachePtr->numObjects >= ALLOC_NOBJHIGH)))) { \ TclThreadFreeObj(objPtr); \ } else { \ (objPtr)->internalRep.ptr = cachePtr->firstObjPtr; \ cachePtr->firstObjPtr = objPtr; \ ++cachePtr->numObjects; \ } \ } while (0) #else /* not PURIFY or USE_THREAD_ALLOC */ |
︙ | ︙ | |||
4367 4368 4369 4370 4371 4372 4373 | do { \ Tcl_MutexLock(&tclObjMutex); \ if (tclFreeObjList == NULL) { \ TclAllocateFreeObjects(); \ } \ (objPtr) = tclFreeObjList; \ tclFreeObjList = (Tcl_Obj *) \ | | | | 4367 4368 4369 4370 4371 4372 4373 4374 4375 4376 4377 4378 4379 4380 4381 4382 4383 4384 4385 4386 4387 4388 | do { \ Tcl_MutexLock(&tclObjMutex); \ if (tclFreeObjList == NULL) { \ TclAllocateFreeObjects(); \ } \ (objPtr) = tclFreeObjList; \ tclFreeObjList = (Tcl_Obj *) \ tclFreeObjList->internalRep.ptr; \ Tcl_MutexUnlock(&tclObjMutex); \ } while (0) # define TclFreeObjStorageEx(interp, objPtr) \ do { \ Tcl_MutexLock(&tclObjMutex); \ (objPtr)->internalRep.ptr = (void *) tclFreeObjList; \ tclFreeObjList = (objPtr); \ Tcl_MutexUnlock(&tclObjMutex); \ } while (0) #endif #else /* TCL_MEM_DEBUG */ MODULE_SCOPE void TclDbInitNewObj(Tcl_Obj *objPtr, const char *file, |
︙ | ︙ | |||
4549 4550 4551 4552 4553 4554 4555 | *---------------------------------------------------------------- */ #define TclUnpackBignum(objPtr, bignum) \ do { \ Tcl_Obj *bignumObj = (objPtr); \ int bignumPayload = \ | | | | | 4549 4550 4551 4552 4553 4554 4555 4556 4557 4558 4559 4560 4561 4562 4563 4564 4565 4566 4567 | *---------------------------------------------------------------- */ #define TclUnpackBignum(objPtr, bignum) \ do { \ Tcl_Obj *bignumObj = (objPtr); \ int bignumPayload = \ bignumObj->internalRep.size2; \ if (bignumPayload == -1) { \ (bignum) = *((mp_int *) bignumObj->internalRep.ptr); \ } else { \ (bignum).dp = (mp_digit *)bignumObj->internalRep.ptr; \ (bignum).sign = bignumPayload >> 30; \ (bignum).alloc = (bignumPayload >> 15) & 0x7FFF; \ (bignum).used = bignumPayload & 0x7FFF; \ } \ } while (0) /* |
︙ | ︙ |
Changes to generic/tclListObj.c.
︙ | ︙ | |||
197 198 199 200 201 202 203 | * ListObjReplaceRepAndInvalidate - Like ListObjOverwriteRep but additionally * assumes the Tcl_Obj internal rep is valid (and possibly even same as * passed ListRep) and frees it first. Additionally invalidates the string * representation. Generally used when modifying a Tcl_Obj value. */ #define ListObjStompRep(objPtr_, repPtr_) \ do { \ | | | | 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 | * ListObjReplaceRepAndInvalidate - Like ListObjOverwriteRep but additionally * assumes the Tcl_Obj internal rep is valid (and possibly even same as * passed ListRep) and frees it first. Additionally invalidates the string * representation. Generally used when modifying a Tcl_Obj value. */ #define ListObjStompRep(objPtr_, repPtr_) \ do { \ (objPtr_)->internalRep.ptr = (repPtr_)->storePtr; \ (objPtr_)->internalRep.ptr2 = (repPtr_)->spanPtr; \ (objPtr_)->typePtr = &tclListType; \ } while (0) #define ListObjOverwriteRep(objPtr_, repPtr_) \ do { \ ListRepIncrRefs(repPtr_); \ ListObjStompRep(objPtr_, repPtr_); \ |
︙ | ︙ | |||
3448 3449 3450 3451 3452 3453 3454 | /* * Note old string representation NOT to be invalidated. * So do NOT use ListObjReplaceRepAndInvalidate. InternalRep to be freed AFTER * IncrRefs so do not use ListObjOverwriteRep */ ListRepIncrRefs(&listRep); TclFreeInternalRep(objPtr); | | | | 3448 3449 3450 3451 3452 3453 3454 3455 3456 3457 3458 3459 3460 3461 3462 3463 | /* * Note old string representation NOT to be invalidated. * So do NOT use ListObjReplaceRepAndInvalidate. InternalRep to be freed AFTER * IncrRefs so do not use ListObjOverwriteRep */ ListRepIncrRefs(&listRep); TclFreeInternalRep(objPtr); objPtr->internalRep.ptr = listRep.storePtr; objPtr->internalRep.ptr2 = listRep.spanPtr; objPtr->typePtr = &tclListType; return TCL_OK; } /* *---------------------------------------------------------------------- |
︙ | ︙ |
Changes to generic/tclNamesp.c.
︙ | ︙ | |||
136 137 138 139 140 141 142 | TCL_OBJTYPE_V0 }; #define NsNameSetInternalRep(objPtr, nnPtr) \ do { \ Tcl_ObjInternalRep ir; \ (nnPtr)->refCount++; \ | | | | | 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 | TCL_OBJTYPE_V0 }; #define NsNameSetInternalRep(objPtr, nnPtr) \ do { \ Tcl_ObjInternalRep ir; \ (nnPtr)->refCount++; \ ir.ptr = (nnPtr); \ ir.ptr2 = NULL; \ Tcl_StoreInternalRep((objPtr), &nsNameType, &ir); \ } while (0) #define NsNameGetInternalRep(objPtr, nnPtr) \ do { \ const Tcl_ObjInternalRep *irPtr; \ irPtr = TclFetchInternalRep((objPtr), &nsNameType); \ (nnPtr) = irPtr ? (ResolvedNsName *) irPtr->ptr : NULL; \ } while (0) /* * Array of values describing how to implement each standard subcommand of the * "namespace" command. */ |
︙ | ︙ |
Changes to generic/tclOOCall.c.
︙ | ︙ | |||
258 259 260 261 262 263 264 | Tcl_Obj *objPtr, CallChain *callPtr) { Tcl_ObjInternalRep ir; callPtr->refCount++; TclGetString(objPtr); | | | 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 | Tcl_Obj *objPtr, CallChain *callPtr) { Tcl_ObjInternalRep ir; callPtr->refCount++; TclGetString(objPtr); ir.ptr = callPtr; Tcl_StoreInternalRep(objPtr, &methodNameType, &ir); } void TclOOStashContext( Tcl_Obj *objPtr, CallContext *contextPtr) |
︙ | ︙ | |||
287 288 289 290 291 292 293 | static void DupMethodNameRep( Tcl_Obj *srcPtr, Tcl_Obj *dstPtr) { StashCallChain(dstPtr, (CallChain *) | | | | 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 | static void DupMethodNameRep( Tcl_Obj *srcPtr, Tcl_Obj *dstPtr) { StashCallChain(dstPtr, (CallChain *) TclFetchInternalRep(srcPtr, &methodNameType)->ptr); } static void FreeMethodNameRep( Tcl_Obj *objPtr) { TclOODeleteChain((CallChain *) TclFetchInternalRep(objPtr, &methodNameType)->ptr); } /* * ---------------------------------------------------------------------- * * TclOOInvokeContext -- * |
︙ | ︙ | |||
1217 1218 1219 1220 1221 1222 1223 | * the object, and in the class). */ const Tcl_ObjInternalRep *irPtr; const int reuseMask = (WANT_PUBLIC(flags) ? ~0 : ~PUBLIC_METHOD); if ((irPtr = TclFetchInternalRep(cacheInThisObj, &methodNameType))) { | | | 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 | * the object, and in the class). */ const Tcl_ObjInternalRep *irPtr; const int reuseMask = (WANT_PUBLIC(flags) ? ~0 : ~PUBLIC_METHOD); if ((irPtr = TclFetchInternalRep(cacheInThisObj, &methodNameType))) { callPtr = (CallChain *) irPtr->ptr; if (IsStillValid(callPtr, oPtr, flags, reuseMask)) { callPtr->refCount++; goto returnContext; } Tcl_StoreInternalRep(cacheInThisObj, &methodNameType, NULL); } |
︙ | ︙ |
Changes to generic/tclObj.c.
︙ | ︙ | |||
176 177 178 179 180 181 182 | * Macros to pack/unpack a bignum's fields in a Tcl_Obj internal rep */ #define PACK_BIGNUM(bignum, objPtr) \ if ((bignum).used > 0x7FFF) { \ mp_int *temp = (mp_int *)Tcl_Alloc(sizeof(mp_int)); \ *temp = bignum; \ | | | | | | | 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 | * Macros to pack/unpack a bignum's fields in a Tcl_Obj internal rep */ #define PACK_BIGNUM(bignum, objPtr) \ if ((bignum).used > 0x7FFF) { \ mp_int *temp = (mp_int *)Tcl_Alloc(sizeof(mp_int)); \ *temp = bignum; \ (objPtr)->internalRep.ptr = temp; \ (objPtr)->internalRep.size2 = -1; \ } else if (((bignum).alloc <= 0x7FFF) || (mp_shrink(&(bignum))) == MP_OKAY) { \ (objPtr)->internalRep.ptr = (bignum).dp; \ (objPtr)->internalRep.size2 = ((bignum).sign << 30) \ | ((bignum).alloc << 15) | ((bignum).used); \ } /* * Prototypes for functions defined later in this file: */ static int ParseBoolean(Tcl_Obj *objPtr); |
︙ | ︙ | |||
275 276 277 278 279 280 281 | * The structure below defines the command name Tcl object type by means of * functions that can be invoked by generic object code. Objects of this type * cache the Command pointer that results from looking up command names in the * command hashtable. Such objects appear as the zeroth ("command name") * argument in a Tcl command. * * NOTE: the ResolvedCmdName that gets cached is stored in the | | | 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 | * The structure below defines the command name Tcl object type by means of * functions that can be invoked by generic object code. Objects of this type * cache the Command pointer that results from looking up command names in the * command hashtable. Such objects appear as the zeroth ("command name") * argument in a Tcl command. * * NOTE: the ResolvedCmdName that gets cached is stored in the * ptr field, and the ptr2 field is unused. You might * think you could use the simpler otherValuePtr field to store the single * ResolvedCmdName pointer, but DO NOT DO THIS. It seems that some extensions * use the second internal pointer field of the twoPtrValue field for their * own purposes. * * TRICKY POINT! Some extensions update this structure! (Notably, these * include TclBlend and TCom). This is highly ill-advised on their part, but |
︙ | ︙ | |||
1201 1202 1203 1204 1205 1206 1207 | * * Results: * None. * * Side effects: * tclFreeObjList, the head of the list of free Tcl_Objs, is set to the * first of a number of free Tcl_Obj's linked together by their | | | 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 | * * Results: * None. * * Side effects: * tclFreeObjList, the head of the list of free Tcl_Objs, is set to the * first of a number of free Tcl_Obj's linked together by their * internalRep.ptr's. * *---------------------------------------------------------------------- */ #define OBJS_TO_ALLOC_EACH_TIME 100 void |
︙ | ︙ | |||
1230 1231 1232 1233 1234 1235 1236 | */ basePtr = (char *)Tcl_Alloc(bytesToAlloc); prevPtr = NULL; objPtr = (Tcl_Obj *) basePtr; for (i = 0; i < OBJS_TO_ALLOC_EACH_TIME; i++) { | | | 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 | */ basePtr = (char *)Tcl_Alloc(bytesToAlloc); prevPtr = NULL; objPtr = (Tcl_Obj *) basePtr; for (i = 0; i < OBJS_TO_ALLOC_EACH_TIME; i++) { objPtr->internalRep.ptr = prevPtr; prevPtr = objPtr; objPtr++; } tclFreeObjList = prevPtr; } #undef OBJS_TO_ALLOC_EACH_TIME |
︙ | ︙ | |||
3307 3308 3309 3310 3311 3312 3313 | FreeBignum( Tcl_Obj *objPtr) { mp_int toFree; /* Bignum to free */ TclUnpackBignum(objPtr, toFree); mp_clear(&toFree); | | | | 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 3322 | FreeBignum( Tcl_Obj *objPtr) { mp_int toFree; /* Bignum to free */ TclUnpackBignum(objPtr, toFree); mp_clear(&toFree); if (objPtr->internalRep.size2 < 0) { Tcl_Free(objPtr->internalRep.ptr); } objPtr->typePtr = NULL; } /* *---------------------------------------------------------------------- * |
︙ | ︙ | |||
3518 3519 3520 3521 3522 3523 3524 | TclUnpackBignum(objPtr, temp); if (mp_init_copy(bignumValue, &temp) != MP_OKAY) { return TCL_ERROR; } } else { TclUnpackBignum(objPtr, *bignumValue); /* Optimized TclFreeInternalRep */ | | | | 3518 3519 3520 3521 3522 3523 3524 3525 3526 3527 3528 3529 3530 3531 3532 3533 | TclUnpackBignum(objPtr, temp); if (mp_init_copy(bignumValue, &temp) != MP_OKAY) { return TCL_ERROR; } } else { TclUnpackBignum(objPtr, *bignumValue); /* Optimized TclFreeInternalRep */ objPtr->internalRep.ptr = NULL; objPtr->internalRep.ptr2 = NULL; objPtr->typePtr = NULL; /* * TODO: If objPtr has a string rep, this leaves * it undisturbed. Not clear that's proper. Pure * bignum values are converted to empty string. */ if (objPtr->bytes == NULL) { |
︙ | ︙ | |||
4411 4412 4413 4414 4415 4416 4417 | * Check also that the command's epoch is up to date, and that the command * is not deleted. * * If any check fails, then force another conversion to the command type, * to discard the old rep and create a new one. */ | | | 4411 4412 4413 4414 4415 4416 4417 4418 4419 4420 4421 4422 4423 4424 4425 | * Check also that the command's epoch is up to date, and that the command * is not deleted. * * If any check fails, then force another conversion to the command type, * to discard the old rep and create a new one. */ resPtr = (ResolvedCmdName *)objPtr->internalRep.ptr; if (TclHasInternalRep(objPtr, &tclCmdNameType)) { Command *cmdPtr = resPtr->cmdPtr; if ((cmdPtr->cmdEpoch == resPtr->cmdEpoch) && (interp == cmdPtr->nsPtr->interp) && !(cmdPtr->nsPtr->flags & NS_DYING)) { Namespace *refNsPtr = (Namespace *) |
︙ | ︙ | |||
4439 4440 4441 4442 4443 4444 4445 | * had is invalid one way or another. */ /* See [07d13d99b0a9] why we cannot call SetCmdNameFromAny() directly here. */ if (tclCmdNameType.setFromAnyProc(interp, objPtr) != TCL_OK) { return NULL; } | | | 4439 4440 4441 4442 4443 4444 4445 4446 4447 4448 4449 4450 4451 4452 4453 | * had is invalid one way or another. */ /* See [07d13d99b0a9] why we cannot call SetCmdNameFromAny() directly here. */ if (tclCmdNameType.setFromAnyProc(interp, objPtr) != TCL_OK) { return NULL; } resPtr = (ResolvedCmdName *)objPtr->internalRep.ptr; return (Tcl_Command) (resPtr ? resPtr->cmdPtr : NULL); } /* *---------------------------------------------------------------------- * * TclSetCmdNameObj -- |
︙ | ︙ | |||
4510 4511 4512 4513 4514 4515 4516 | fillPtr->refNsId = currNsPtr->nsId; fillPtr->refNsCmdEpoch = currNsPtr->cmdRefEpoch; } if (resPtr == NULL) { TclFreeInternalRep(objPtr); | | | | | 4510 4511 4512 4513 4514 4515 4516 4517 4518 4519 4520 4521 4522 4523 4524 4525 4526 4527 4528 4529 4530 4531 4532 4533 4534 4535 4536 4537 4538 4539 4540 4541 4542 | fillPtr->refNsId = currNsPtr->nsId; fillPtr->refNsCmdEpoch = currNsPtr->cmdRefEpoch; } if (resPtr == NULL) { TclFreeInternalRep(objPtr); objPtr->internalRep.ptr = fillPtr; objPtr->internalRep.ptr2 = NULL; objPtr->typePtr = &tclCmdNameType; } } void TclSetCmdNameObj( Tcl_Interp *interp, /* Points to interpreter containing command * that should be cached in objPtr. */ Tcl_Obj *objPtr, /* Points to Tcl object to be changed to a * CmdName object. */ Command *cmdPtr) /* Points to Command structure that the * CmdName object should refer to. */ { ResolvedCmdName *resPtr; if (TclHasInternalRep(objPtr, &tclCmdNameType)) { resPtr = (ResolvedCmdName *)objPtr->internalRep.ptr; if (resPtr != NULL && resPtr->cmdPtr == cmdPtr) { return; } } SetCmdNameObj(interp, objPtr, cmdPtr, NULL); } |
︙ | ︙ | |||
4563 4564 4565 4566 4567 4568 4569 | */ static void FreeCmdNameInternalRep( Tcl_Obj *objPtr) /* CmdName object with internal * representation to free. */ { | | | 4563 4564 4565 4566 4567 4568 4569 4570 4571 4572 4573 4574 4575 4576 4577 | */ static void FreeCmdNameInternalRep( Tcl_Obj *objPtr) /* CmdName object with internal * representation to free. */ { ResolvedCmdName *resPtr = (ResolvedCmdName *)objPtr->internalRep.ptr; /* * Decrement the reference count of the ResolvedCmdName structure. If * there are no more uses, free the ResolvedCmdName structure. */ if (resPtr->refCount-- <= 1) { |
︙ | ︙ | |||
4610 4611 4612 4613 4614 4615 4616 | */ static void DupCmdNameInternalRep( Tcl_Obj *srcPtr, /* Object with internal rep to copy. */ Tcl_Obj *copyPtr) /* Object with internal rep to set. */ { | | | | | 4610 4611 4612 4613 4614 4615 4616 4617 4618 4619 4620 4621 4622 4623 4624 4625 4626 4627 | */ static void DupCmdNameInternalRep( Tcl_Obj *srcPtr, /* Object with internal rep to copy. */ Tcl_Obj *copyPtr) /* Object with internal rep to set. */ { ResolvedCmdName *resPtr = (ResolvedCmdName *)srcPtr->internalRep.ptr; copyPtr->internalRep.ptr = resPtr; copyPtr->internalRep.ptr2 = NULL; resPtr->refCount++; copyPtr->typePtr = &tclCmdNameType; } /* *---------------------------------------------------------------------- * |
︙ | ︙ | |||
4673 4674 4675 4676 4677 4678 4679 | * report the failure to find the command as an error. */ if (cmdPtr == NULL || !TclRoutineHasName(cmdPtr)) { return TCL_ERROR; } | | | 4673 4674 4675 4676 4677 4678 4679 4680 4681 4682 4683 4684 4685 4686 4687 | * report the failure to find the command as an error. */ if (cmdPtr == NULL || !TclRoutineHasName(cmdPtr)) { return TCL_ERROR; } resPtr = (ResolvedCmdName *)objPtr->internalRep.ptr; if (TclHasInternalRep(objPtr, &tclCmdNameType) && (resPtr->refCount == 1)) { /* * Re-use existing ResolvedCmdName struct when possible. * Cleanup the old fields that need it. */ Command *oldCmdPtr = resPtr->cmdPtr; |
︙ | ︙ | |||
4740 4741 4742 4743 4744 4745 4746 | if (objv[1]->typePtr) { if (TclHasInternalRep(objv[1], &tclDoubleType)) { Tcl_AppendPrintfToObj(descObj, ", internal representation %g", objv[1]->internalRep.doubleValue); } else { Tcl_AppendPrintfToObj(descObj, ", internal representation %p:%p", | | | | 4740 4741 4742 4743 4744 4745 4746 4747 4748 4749 4750 4751 4752 4753 4754 4755 | if (objv[1]->typePtr) { if (TclHasInternalRep(objv[1], &tclDoubleType)) { Tcl_AppendPrintfToObj(descObj, ", internal representation %g", objv[1]->internalRep.doubleValue); } else { Tcl_AppendPrintfToObj(descObj, ", internal representation %p:%p", (void *) objv[1]->internalRep.ptr, (void *) objv[1]->internalRep.ptr2); } } if (objv[1]->bytes) { Tcl_AppendToObj(descObj, ", string representation \"", -1); Tcl_AppendLimitedToObj(descObj, objv[1]->bytes, objv[1]->length, 16, "..."); |
︙ | ︙ |
Changes to generic/tclPathObj.c.
︙ | ︙ | |||
85 86 87 88 89 90 91 | #define TCLPATH_NEEDNORM 4 /* * Define some macros to give us convenient access to path-object specific * fields. */ | | | | | 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 | #define TCLPATH_NEEDNORM 4 /* * Define some macros to give us convenient access to path-object specific * fields. */ #define PATHOBJ(pathPtr) ((FsPath *) (TclFetchInternalRep((pathPtr), &fsPathType)->ptr)) #define SETPATHOBJ(pathPtr,fsPathPtr) \ do { \ Tcl_ObjInternalRep ir; \ ir.ptr = (void *) (fsPathPtr); \ ir.ptr2 = NULL; \ Tcl_StoreInternalRep((pathPtr), &fsPathType, &ir); \ } while (0) #define PATHFLAGS(pathPtr) (PATHOBJ(pathPtr)->flags) /* *--------------------------------------------------------------------------- * |
︙ | ︙ |
Changes to generic/tclProc.c.
︙ | ︙ | |||
69 70 71 72 73 74 75 | TCL_OBJTYPE_V0 }; #define ProcSetInternalRep(objPtr, procPtr) \ do { \ Tcl_ObjInternalRep ir; \ (procPtr)->refCount++; \ | | | | | 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 | TCL_OBJTYPE_V0 }; #define ProcSetInternalRep(objPtr, procPtr) \ do { \ Tcl_ObjInternalRep ir; \ (procPtr)->refCount++; \ ir.ptr = (procPtr); \ ir.ptr2 = NULL; \ Tcl_StoreInternalRep((objPtr), &tclProcBodyType, &ir); \ } while (0) #define ProcGetInternalRep(objPtr, procPtr) \ do { \ const Tcl_ObjInternalRep *irPtr; \ irPtr = TclFetchInternalRep((objPtr), &tclProcBodyType); \ (procPtr) = irPtr ? (Proc *)irPtr->ptr : NULL; \ } while (0) /* * The [upvar]/[uplevel] level reference type. Uses the wideValue field * to remember the integer value of a parsed #<integer> format. * * Uses the default behaviour throughout, and never disposes of the string |
︙ | ︙ | |||
119 120 121 122 123 124 125 | SetLambdaFromAny, /* setFromAnyProc */ TCL_OBJTYPE_V0 }; #define LambdaSetInternalRep(objPtr, procPtr, nsObjPtr) \ do { \ Tcl_ObjInternalRep ir; \ | | | | | | 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 | SetLambdaFromAny, /* setFromAnyProc */ TCL_OBJTYPE_V0 }; #define LambdaSetInternalRep(objPtr, procPtr, nsObjPtr) \ do { \ Tcl_ObjInternalRep ir; \ ir.ptr = (procPtr); \ ir.ptr2 = (nsObjPtr); \ Tcl_IncrRefCount((nsObjPtr)); \ Tcl_StoreInternalRep((objPtr), &lambdaType, &ir); \ } while (0) #define LambdaGetInternalRep(objPtr, procPtr, nsObjPtr) \ do { \ const Tcl_ObjInternalRep *irPtr; \ irPtr = TclFetchInternalRep((objPtr), &lambdaType); \ (procPtr) = irPtr ? (Proc *)irPtr->ptr : NULL; \ (nsObjPtr) = irPtr ? (Tcl_Obj *)irPtr->ptr2 : NULL; \ } while (0) /* *---------------------------------------------------------------------- * * Tcl_ProcObjCmd -- * |
︙ | ︙ |
Changes to generic/tclRegexp.c.
︙ | ︙ | |||
111 112 113 114 115 116 117 | TCL_OBJTYPE_V0 }; #define RegexpSetInternalRep(objPtr, rePtr) \ do { \ Tcl_ObjInternalRep ir; \ (rePtr)->refCount++; \ | | | | | 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 | TCL_OBJTYPE_V0 }; #define RegexpSetInternalRep(objPtr, rePtr) \ do { \ Tcl_ObjInternalRep ir; \ (rePtr)->refCount++; \ ir.ptr = (rePtr); \ ir.ptr2 = NULL; \ Tcl_StoreInternalRep((objPtr), &tclRegexpType, &ir); \ } while (0) #define RegexpGetInternalRep(objPtr, rePtr) \ do { \ const Tcl_ObjInternalRep *irPtr; \ irPtr = TclFetchInternalRep((objPtr), &tclRegexpType); \ (rePtr) = irPtr ? (TclRegexp *)irPtr->ptr : NULL; \ } while (0) /* *---------------------------------------------------------------------- * * Tcl_RegExpCompile -- * |
︙ | ︙ |
Changes to generic/tclStrIdxTree.c.
︙ | ︙ | |||
355 356 357 358 359 360 361 | /* Is a Tcl_Obj (of right type) holding a smart pointer link? */ static inline int IsLink( Tcl_Obj *objPtr) { Tcl_ObjInternalRep *irPtr = &objPtr->internalRep; | | | | | 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 | /* Is a Tcl_Obj (of right type) holding a smart pointer link? */ static inline int IsLink( Tcl_Obj *objPtr) { Tcl_ObjInternalRep *irPtr = &objPtr->internalRep; return irPtr->ptr && !irPtr->ptr2; } /* Follow links (smart pointers) if present. */ static inline Tcl_Obj * FollowPossibleLink( Tcl_Obj *objPtr) { if (IsLink(objPtr)) { objPtr = (Tcl_Obj *) objPtr->internalRep.ptr; } /* assert(!IsLink(objPtr)); */ return objPtr; } Tcl_Obj * TclStrIdxTreeNewObj(void) { Tcl_Obj *objPtr = Tcl_NewObj(); TclStrIdxTree *tree = (TclStrIdxTree *) &objPtr->internalRep; /* * This assert states that we can safely directly have a tree node as the * internal representation of a Tcl_Obj instead of needing to hang it * off the back with an extra alloc. */ TCL_CT_ASSERT(sizeof(TclStrIdxTree) <= sizeof(Tcl_ObjInternalRep)); |
︙ | ︙ | |||
399 400 401 402 403 404 405 | Tcl_Obj *srcPtr, Tcl_Obj *copyPtr) { /* follow links (smart pointers) */ srcPtr = FollowPossibleLink(srcPtr); /* create smart pointer to it (ptr1 != NULL, ptr2 = NULL) */ | | | | | | 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 | Tcl_Obj *srcPtr, Tcl_Obj *copyPtr) { /* follow links (smart pointers) */ srcPtr = FollowPossibleLink(srcPtr); /* create smart pointer to it (ptr1 != NULL, ptr2 = NULL) */ TclInitObjRef(*((Tcl_Obj **) ©Ptr->internalRep.ptr), srcPtr); copyPtr->internalRep.ptr2 = NULL; copyPtr->typePtr = &StrIdxTreeObjType; } static void StrIdxTreeObj_FreeIntRepProc( Tcl_Obj *objPtr) { /* follow links (smart pointers) */ if (IsLink(objPtr)) { /* is a link */ TclUnsetObjRef(*((Tcl_Obj **) &objPtr->internalRep.ptr)); } else { /* is a tree */ TclStrIdxTree *tree = (TclStrIdxTree *) &objPtr->internalRep; if (tree->firstPtr != NULL) { TclStrIdxTreeFree(tree->firstPtr); } tree->firstPtr = NULL; tree->lastPtr = NULL; } |
︙ | ︙ | |||
447 448 449 450 451 452 453 | return NULL; } /* follow links (smart pointers) */ objPtr = FollowPossibleLink(objPtr); /* return tree root in internal representation */ | | | 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 | return NULL; } /* follow links (smart pointers) */ objPtr = FollowPossibleLink(objPtr); /* return tree root in internal representation */ return (TclStrIdxTree *) &objPtr->internalRep; } /* * Several debug primitives */ #ifdef TEST_STR_IDX_TREE /* currently unused, debug resp. test purposes only */ |
︙ | ︙ |
Changes to generic/tclStringRep.h.
︙ | ︙ | |||
57 58 59 60 61 62 63 | #define stringAlloc(numChars) \ (String *) Tcl_Alloc(STRING_SIZE(numChars)) #define stringRealloc(ptr, numChars) \ (String *) Tcl_Realloc((ptr), STRING_SIZE(numChars)) #define stringAttemptRealloc(ptr, numChars) \ (String *) Tcl_AttemptRealloc((ptr), STRING_SIZE(numChars)) #define GET_STRING(objPtr) \ | | | | | 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 | #define stringAlloc(numChars) \ (String *) Tcl_Alloc(STRING_SIZE(numChars)) #define stringRealloc(ptr, numChars) \ (String *) Tcl_Realloc((ptr), STRING_SIZE(numChars)) #define stringAttemptRealloc(ptr, numChars) \ (String *) Tcl_AttemptRealloc((ptr), STRING_SIZE(numChars)) #define GET_STRING(objPtr) \ ((String *) (objPtr)->internalRep.ptr) #define SET_STRING(objPtr, stringPtr) \ ((objPtr)->internalRep.ptr2 = NULL), \ ((objPtr)->internalRep.ptr = (void *) (stringPtr)) #endif /* _TCLSTRINGREP */ /* * Local Variables: * mode: c * c-basic-offset: 4 * fill-column: 78 |
︙ | ︙ |
Changes to generic/tclTest.c.
︙ | ︙ | |||
5663 5664 5665 5666 5667 5668 5669 | if (objc > 2) { Tcl_WrongNumArgs(interp, 1, objv, "?string?"); return TCL_ERROR; } objPtr = Tcl_NewObj(); /* | | | | 5663 5664 5665 5666 5667 5668 5669 5670 5671 5672 5673 5674 5675 5676 5677 5678 | if (objc > 2) { Tcl_WrongNumArgs(interp, 1, objv, "?string?"); return TCL_ERROR; } objPtr = Tcl_NewObj(); /* objPtr->internalRep.ptr = NULL; objPtr->internalRep.ptr2 = NULL; */ memset(&objPtr->internalRep, 0, sizeof(objPtr->internalRep)); if (objc == 2) { const char *s = Tcl_GetString(objv[1]); objPtr->length = objv[1]->length; objPtr->bytes = (char *)Tcl_Alloc(objPtr->length + 1); memcpy(objPtr->bytes, s, objPtr->length); |
︙ | ︙ |
Changes to generic/tclTestABSList.c.
︙ | ︙ | |||
262 263 264 265 266 267 268 | static int my_LStringObjIndex( Tcl_Interp *interp, Tcl_Obj *lstringObj, Tcl_Size index, Tcl_Obj **charObjPtr) { | | | 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 | static int my_LStringObjIndex( Tcl_Interp *interp, Tcl_Obj *lstringObj, Tcl_Size index, Tcl_Obj **charObjPtr) { LString *lstringRepPtr = (LString*)lstringObj->internalRep.ptr; (void)interp; if (index < lstringRepPtr->strlen) { char cchar[2]; cchar[0] = lstringRepPtr->string[index]; cchar[1] = 0; |
︙ | ︙ | |||
299 300 301 302 303 304 305 | * *---------------------------------------------------------------------- */ static Tcl_Size my_LStringObjLength(Tcl_Obj *lstringObjPtr) { | | | 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 | * *---------------------------------------------------------------------- */ static Tcl_Size my_LStringObjLength(Tcl_Obj *lstringObjPtr) { LString *lstringRepPtr = (LString *)lstringObjPtr->internalRep.ptr; return lstringRepPtr->strlen; } /* *---------------------------------------------------------------------- * |
︙ | ︙ | |||
324 325 326 327 328 329 330 | * *---------------------------------------------------------------------- */ static void DupLStringRep(Tcl_Obj *srcPtr, Tcl_Obj *copyPtr) { | | | | | 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 | * *---------------------------------------------------------------------- */ static void DupLStringRep(Tcl_Obj *srcPtr, Tcl_Obj *copyPtr) { LString *srcLString = (LString*)srcPtr->internalRep.ptr; LString *copyLString = (LString*)Tcl_Alloc(sizeof(LString)); memcpy(copyLString, srcLString, sizeof(LString)); copyLString->string = (char*)Tcl_Alloc(srcLString->allocated); strncpy(copyLString->string, srcLString->string, srcLString->strlen); copyLString->string[srcLString->strlen] = '\0'; copyLString->elements = NULL; Tcl_ObjInternalRep itr; itr.ptr = copyLString; itr.ptr2 = NULL; Tcl_StoreInternalRep(copyPtr, srcPtr->typePtr, &itr); return; } /* *---------------------------------------------------------------------- |
︙ | ︙ | |||
368 369 370 371 372 373 374 | my_LStringObjSetElem( Tcl_Interp *interp, Tcl_Obj *lstringObj, Tcl_Size numIndicies, Tcl_Obj *const indicies[], Tcl_Obj *valueObj) { | | | | 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 | my_LStringObjSetElem( Tcl_Interp *interp, Tcl_Obj *lstringObj, Tcl_Size numIndicies, Tcl_Obj *const indicies[], Tcl_Obj *valueObj) { LString *lstringRepPtr = (LString*)lstringObj->internalRep.ptr; Tcl_Size index; int status; Tcl_Obj *returnObj; if (numIndicies > 1) { Tcl_SetObjResult(interp, Tcl_ObjPrintf("Multiple indicies not supported by lstring.")); return NULL; } status = Tcl_GetIntForIndex(interp, indicies[0], lstringRepPtr->strlen, &index); if (status != TCL_OK) { return NULL; } returnObj = Tcl_IsShared(lstringObj) ? Tcl_DuplicateObj(lstringObj) : lstringObj; lstringRepPtr = (LString*)returnObj->internalRep.ptr; if (index >= lstringRepPtr->strlen) { index = lstringRepPtr->strlen; lstringRepPtr->strlen++; lstringRepPtr->string = (char*)Tcl_Realloc(lstringRepPtr->string, lstringRepPtr->strlen+1); } |
︙ | ︙ | |||
434 435 436 437 438 439 440 | Tcl_Interp *interp, Tcl_Obj *lstringObj, Tcl_Size fromIdx, Tcl_Size toIdx, Tcl_Obj **newObjPtr) { Tcl_Obj *rangeObj; | | | 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 | Tcl_Interp *interp, Tcl_Obj *lstringObj, Tcl_Size fromIdx, Tcl_Size toIdx, Tcl_Obj **newObjPtr) { Tcl_Obj *rangeObj; LString *lstringRepPtr = (LString*)lstringObj->internalRep.ptr; LString *rangeRep; Tcl_WideInt len = toIdx - fromIdx + 1; if (lstringRepPtr->strlen < fromIdx || lstringRepPtr->strlen < toIdx) { Tcl_SetObjResult(interp, Tcl_ObjPrintf("Range out of bounds ")); |
︙ | ︙ | |||
458 459 460 461 462 463 464 | rangeRep->strlen = len; rangeRep->string = (char*)Tcl_Alloc(rangeRep->allocated); strncpy(rangeRep->string,&lstringRepPtr->string[fromIdx],len); rangeRep->string[len] = 0; rangeRep->elements = NULL; rangeObj = Tcl_NewObj(); Tcl_ObjInternalRep itr; | | | | 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 | rangeRep->strlen = len; rangeRep->string = (char*)Tcl_Alloc(rangeRep->allocated); strncpy(rangeRep->string,&lstringRepPtr->string[fromIdx],len); rangeRep->string[len] = 0; rangeRep->elements = NULL; rangeObj = Tcl_NewObj(); Tcl_ObjInternalRep itr; itr.ptr = rangeRep; itr.ptr2 = NULL; Tcl_StoreInternalRep(rangeObj, lstringObj->typePtr, &itr); if (rangeRep->strlen > 0) { Tcl_InvalidateStringRep(rangeObj); } else { Tcl_InitStringRep(rangeObj, NULL, 0); } *newObjPtr = rangeObj; |
︙ | ︙ | |||
491 492 493 494 495 496 497 | * *---------------------------------------------------------------------- */ static int my_LStringObjReverse(Tcl_Interp *interp, Tcl_Obj *srcObj, Tcl_Obj **newObjPtr) { | | | | | 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 | * *---------------------------------------------------------------------- */ static int my_LStringObjReverse(Tcl_Interp *interp, Tcl_Obj *srcObj, Tcl_Obj **newObjPtr) { LString *srcRep = (LString*)srcObj->internalRep.ptr; Tcl_Obj *revObj; LString *revRep = (LString*)Tcl_Alloc(sizeof(LString)); Tcl_ObjInternalRep itr; Tcl_Size len; char *srcp, *dstp, *endp; (void)interp; len = srcRep->strlen; revRep->strlen = len; revRep->allocated = len+1; revRep->string = (char*)Tcl_Alloc(revRep->allocated); revRep->elements = NULL; srcp = srcRep->string; endp = &srcRep->string[len]; dstp = &revRep->string[len]; *dstp-- = 0; while (srcp < endp) { *dstp-- = *srcp++; } revObj = Tcl_NewObj(); itr.ptr = revRep; itr.ptr2 = NULL; Tcl_StoreInternalRep(revObj, srcObj->typePtr, &itr); if (revRep->strlen > 0) { Tcl_InvalidateStringRep(revObj); } else { Tcl_InitStringRep(revObj, NULL, 0); } *newObjPtr = revObj; |
︙ | ︙ | |||
550 551 552 553 554 555 556 | Tcl_Interp *interp, Tcl_Obj *listObj, Tcl_Size first, Tcl_Size numToDelete, Tcl_Size numToInsert, Tcl_Obj *const insertObjs[]) { | | | 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 | Tcl_Interp *interp, Tcl_Obj *listObj, Tcl_Size first, Tcl_Size numToDelete, Tcl_Size numToInsert, Tcl_Obj *const insertObjs[]) { LString *lstringRep = (LString*)listObj->internalRep.ptr; Tcl_Size newLen; Tcl_Size x, ix, kx; char *newStr; char *oldStr = lstringRep->string; (void)interp; newLen = lstringRep->strlen - numToDelete + numToInsert; |
︙ | ︙ | |||
713 714 715 716 717 718 719 | lstringRepPtr->strlen = strlen(string); lstringRepPtr->allocated = lstringRepPtr->strlen + 1; lstringRepPtr->string = (char*)Tcl_Alloc(lstringRepPtr->allocated); strcpy(lstringRepPtr->string, string); lstringRepPtr->elements = NULL; lstringPtr = Tcl_NewObj(); | | | | 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 | lstringRepPtr->strlen = strlen(string); lstringRepPtr->allocated = lstringRepPtr->strlen + 1; lstringRepPtr->string = (char*)Tcl_Alloc(lstringRepPtr->allocated); strcpy(lstringRepPtr->string, string); lstringRepPtr->elements = NULL; lstringPtr = Tcl_NewObj(); itr.ptr = lstringRepPtr; itr.ptr2 = NULL; Tcl_StoreInternalRep(lstringPtr, lstringTypePtr, &itr); if (lstringRepPtr->strlen > 0) { Tcl_InvalidateStringRep(lstringPtr); } else { Tcl_InitStringRep(lstringPtr, NULL, 0); } return lstringPtr; |
︙ | ︙ | |||
736 737 738 739 740 741 742 | * Free the element array * */ static void lstringFreeElements(Tcl_Obj* lstringObj) { | | | 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 | * Free the element array * */ static void lstringFreeElements(Tcl_Obj* lstringObj) { LString *lstringRepPtr = (LString*)lstringObj->internalRep.ptr; if (lstringRepPtr->elements) { Tcl_Obj **objptr = lstringRepPtr->elements; while (objptr < &lstringRepPtr->elements[lstringRepPtr->strlen]) { Tcl_DecrRefCount(*objptr++); } Tcl_Free((char*)lstringRepPtr->elements); lstringRepPtr->elements = NULL; |
︙ | ︙ | |||
766 767 768 769 770 771 772 | * *---------------------------------------------------------------------- */ static void freeRep(Tcl_Obj* lstringObj) { | | | | 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 | * *---------------------------------------------------------------------- */ static void freeRep(Tcl_Obj* lstringObj) { LString *lstringRepPtr = (LString*)lstringObj->internalRep.ptr; if (lstringRepPtr->string) { Tcl_Free(lstringRepPtr->string); } lstringFreeElements(lstringObj); Tcl_Free((char*)lstringRepPtr); lstringObj->internalRep.ptr = NULL; } /* *---------------------------------------------------------------------- * * my_LStringGetElements -- * |
︙ | ︙ | |||
796 797 798 799 800 801 802 | */ static int my_LStringGetElements(Tcl_Interp *interp, Tcl_Obj *lstringObj, Tcl_Size *objcptr, Tcl_Obj ***objvptr) { | | | 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 | */ static int my_LStringGetElements(Tcl_Interp *interp, Tcl_Obj *lstringObj, Tcl_Size *objcptr, Tcl_Obj ***objvptr) { LString *lstringRepPtr = (LString*)lstringObj->internalRep.ptr; Tcl_Obj **objPtr; char *cptr = lstringRepPtr->string; (void)interp; if (lstringRepPtr->strlen == 0) { *objcptr = 0; *objvptr = NULL; return TCL_OK; |
︙ | ︙ | |||
964 965 966 967 968 969 970 | * The provided funtion computes the value for a give index */ static Tcl_Obj* lgen( Tcl_Obj* objPtr, Tcl_Size index) { | | | 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 | * The provided funtion computes the value for a give index */ static Tcl_Obj* lgen( Tcl_Obj* objPtr, Tcl_Size index) { LgenSeries *lgenSeriesPtr = (LgenSeries*)objPtr->internalRep.ptr; Tcl_Obj *elemObj = NULL; Tcl_Interp *intrp = lgenSeriesPtr->interp; Tcl_Obj *genCmd = lgenSeriesPtr->genFnObj; Tcl_Size endidx = lgenSeriesPtr->nargs-1; if (0 <= index && index < lgenSeriesPtr->len) { Tcl_Obj *indexObj = Tcl_NewWideIntObj(index); |
︙ | ︙ | |||
994 995 996 997 998 999 1000 | /* * Abstract List Length function */ static Tcl_Size lgenSeriesObjLength(Tcl_Obj *objPtr) { | | | | 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 | /* * Abstract List Length function */ static Tcl_Size lgenSeriesObjLength(Tcl_Obj *objPtr) { LgenSeries *lgenSeriesRepPtr = (LgenSeries *)objPtr->internalRep.ptr; return lgenSeriesRepPtr->len; } /* * Abstract List Index function */ static int lgenSeriesObjIndex( Tcl_Interp *interp, Tcl_Obj *lgenSeriesObjPtr, Tcl_Size index, Tcl_Obj **elemPtr) { LgenSeries *lgenSeriesRepPtr; Tcl_Obj *element; lgenSeriesRepPtr = (LgenSeries*)lgenSeriesObjPtr->internalRep.ptr; if (index < 0 || index >= lgenSeriesRepPtr->len) { *elemPtr = NULL; return TCL_OK; } if (lgenSeriesRepPtr->interp == NULL && interp == NULL) { return TCL_ERROR; |
︙ | ︙ | |||
1046 1047 1048 1049 1050 1051 1052 | { LgenSeries *lgenSeriesRepPtr; Tcl_Obj *element; Tcl_Size i; size_t bytlen; Tcl_Obj *tmpstr = Tcl_NewObj(); | | | 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 | { LgenSeries *lgenSeriesRepPtr; Tcl_Obj *element; Tcl_Size i; size_t bytlen; Tcl_Obj *tmpstr = Tcl_NewObj(); lgenSeriesRepPtr = (LgenSeries*)objPtr->internalRep.ptr; for (i=0, bytlen=0; i<lgenSeriesRepPtr->len; i++) { element = lgen(objPtr, i); if (element) { if (i) { Tcl_AppendToObj(tmpstr," ",1); } |
︙ | ︙ | |||
1071 1072 1073 1074 1075 1076 1077 | /* * ObjType Free Internal Rep function */ static void FreeLgenInternalRep(Tcl_Obj *objPtr) { | | | | 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 | /* * ObjType Free Internal Rep function */ static void FreeLgenInternalRep(Tcl_Obj *objPtr) { LgenSeries *lgenSeries = (LgenSeries*)objPtr->internalRep.ptr; if (lgenSeries->genFnObj) { Tcl_DecrRefCount(lgenSeries->genFnObj); } lgenSeries->interp = NULL; Tcl_Free(lgenSeries); objPtr->internalRep.ptr = 0; } static void DupLgenSeriesRep(Tcl_Obj *srcPtr, Tcl_Obj *copyPtr); /* * Abstract List ObjType definition */ |
︙ | ︙ | |||
1111 1112 1113 1114 1115 1116 1117 | * ObjType Duplicate Internal Rep Function */ static void DupLgenSeriesRep( Tcl_Obj *srcPtr, Tcl_Obj *copyPtr) { | | | | | 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 | * ObjType Duplicate Internal Rep Function */ static void DupLgenSeriesRep( Tcl_Obj *srcPtr, Tcl_Obj *copyPtr) { LgenSeries *srcLgenSeries = (LgenSeries*)srcPtr->internalRep.ptr; Tcl_Size repSize = sizeof(LgenSeries); LgenSeries *copyLgenSeries = (LgenSeries*)Tcl_Alloc(repSize); copyLgenSeries->interp = srcLgenSeries->interp; copyLgenSeries->nargs = srcLgenSeries->nargs; copyLgenSeries->len = srcLgenSeries->len; copyLgenSeries->genFnObj = Tcl_DuplicateObj(srcLgenSeries->genFnObj); Tcl_IncrRefCount(copyLgenSeries->genFnObj); copyPtr->typePtr = &lgenType; copyPtr->internalRep.ptr = copyLgenSeries; copyPtr->internalRep.ptr2 = NULL; return; } /* * Create a new lgen Tcl_Obj */ Tcl_Obj * |
︙ | ︙ | |||
1164 1165 1166 1167 1168 1169 1170 | // argsv 0 1 2 3 ... index lGenSeriesRepPtr->nargs = objc; lGenSeriesRepPtr->genFnObj = Tcl_NewListObj(objc-1, objv+1); // Addd 0 placeholder for index Tcl_ListObjAppendElement(interp, lGenSeriesRepPtr->genFnObj, Tcl_NewIntObj(0)); Tcl_IncrRefCount(lGenSeriesRepPtr->genFnObj); | | | | 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 | // argsv 0 1 2 3 ... index lGenSeriesRepPtr->nargs = objc; lGenSeriesRepPtr->genFnObj = Tcl_NewListObj(objc-1, objv+1); // Addd 0 placeholder for index Tcl_ListObjAppendElement(interp, lGenSeriesRepPtr->genFnObj, Tcl_NewIntObj(0)); Tcl_IncrRefCount(lGenSeriesRepPtr->genFnObj); lGenSeriesObj->internalRep.ptr = lGenSeriesRepPtr; lGenSeriesObj->internalRep.ptr2 = NULL; lGenSeriesObj->typePtr = &lgenType; if (length > 0) { Tcl_InvalidateStringRep(lGenSeriesObj); } else { Tcl_InitStringRep(lGenSeriesObj, NULL, 0); } |
︙ | ︙ |
Changes to generic/tclTestObj.c.
︙ | ︙ | |||
603 604 605 606 607 608 609 | */ if (Tcl_GetIntForIndex(interp, objv[2], TCL_INDEX_NONE, &index2) != TCL_OK) { return TCL_ERROR; } Tcl_GetIndexFromObj(NULL, objv[1], tablePtr, "token", 0, &index); | | | 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 | */ if (Tcl_GetIntForIndex(interp, objv[2], TCL_INDEX_NONE, &index2) != TCL_OK) { return TCL_ERROR; } Tcl_GetIndexFromObj(NULL, objv[1], tablePtr, "token", 0, &index); indexRep = (struct IndexRep *)objv[1]->internalRep.ptr; indexRep->index = index2; result = Tcl_GetIndexFromObj(NULL, objv[1], tablePtr, "token", 0, &index); if (result == TCL_OK) { Tcl_SetWideIntObj(Tcl_GetObjResult(interp), index); } return result; |
︙ | ︙ | |||
1425 1426 1427 1428 1429 1430 1431 | case 5: /* length2 */ if (objc != 3) { goto wrongNumArgs; } if (varPtr[varIndex] != NULL) { Tcl_ConvertToType(NULL, varPtr[varIndex], Tcl_GetObjType("string")); | | | 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 | case 5: /* length2 */ if (objc != 3) { goto wrongNumArgs; } if (varPtr[varIndex] != NULL) { Tcl_ConvertToType(NULL, varPtr[varIndex], Tcl_GetObjType("string")); strPtr = (String *)varPtr[varIndex]->internalRep.ptr; length = strPtr->allocated; } else { length = TCL_INDEX_NONE; } Tcl_SetWideIntObj(Tcl_GetObjResult(interp), (Tcl_WideInt)((Tcl_WideUInt)(length + 1U)) - 1); break; case 6: /* set */ |
︙ | ︙ | |||
1479 1480 1481 1482 1483 1484 1485 | case 9: /* maxchars */ if (objc != 3) { goto wrongNumArgs; } if (varPtr[varIndex] != NULL) { Tcl_ConvertToType(NULL, varPtr[varIndex], Tcl_GetObjType("string")); | | | 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 | case 9: /* maxchars */ if (objc != 3) { goto wrongNumArgs; } if (varPtr[varIndex] != NULL) { Tcl_ConvertToType(NULL, varPtr[varIndex], Tcl_GetObjType("string")); strPtr = (String *)varPtr[varIndex]->internalRep.ptr; length = strPtr->maxChars; } else { length = TCL_INDEX_NONE; } Tcl_SetWideIntObj(Tcl_GetObjResult(interp), length); break; case 10: { /* range */ |
︙ | ︙ |
Changes to generic/tclThreadAlloc.c.
︙ | ︙ | |||
539 540 541 542 543 544 545 | newObjsPtr = (Tcl_Obj *)TclpSysAlloc(sizeof(Tcl_Obj) * numMove); if (newObjsPtr == NULL) { Tcl_Panic("alloc: could not allocate %" TCL_Z_MODIFIER "u new objects", numMove); } cachePtr->lastPtr = newObjsPtr + numMove - 1; objPtr = cachePtr->firstObjPtr; /* NULL */ while (numMove-- > 0) { | | | | 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 | newObjsPtr = (Tcl_Obj *)TclpSysAlloc(sizeof(Tcl_Obj) * numMove); if (newObjsPtr == NULL) { Tcl_Panic("alloc: could not allocate %" TCL_Z_MODIFIER "u new objects", numMove); } cachePtr->lastPtr = newObjsPtr + numMove - 1; objPtr = cachePtr->firstObjPtr; /* NULL */ while (numMove-- > 0) { newObjsPtr[numMove].internalRep.ptr = objPtr; objPtr = newObjsPtr + numMove; } cachePtr->firstObjPtr = newObjsPtr; } } /* * Pop the first object. */ objPtr = cachePtr->firstObjPtr; cachePtr->firstObjPtr = (Tcl_Obj *)objPtr->internalRep.ptr; cachePtr->numObjects--; return objPtr; } /* *---------------------------------------------------------------------- * |
︙ | ︙ | |||
588 589 590 591 592 593 594 | GETCACHE(cachePtr); /* * Get this thread's list and push on the free Tcl_Obj. */ | | | 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 | GETCACHE(cachePtr); /* * Get this thread's list and push on the free Tcl_Obj. */ objPtr->internalRep.ptr = cachePtr->firstObjPtr; cachePtr->firstObjPtr = objPtr; if (cachePtr->numObjects == 0) { cachePtr->lastPtr = objPtr; } cachePtr->numObjects++; /* |
︙ | ︙ | |||
690 691 692 693 694 695 696 | /* * Find the last object to be moved; set the next one (the first one not * to be moved) as the first object in the 'from' cache. */ while (numMove-- > 1) { | | | | | 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 | /* * Find the last object to be moved; set the next one (the first one not * to be moved) as the first object in the 'from' cache. */ while (numMove-- > 1) { objPtr = (Tcl_Obj *)objPtr->internalRep.ptr; } fromPtr->firstObjPtr = (Tcl_Obj *)objPtr->internalRep.ptr; /* * Move all objects as a block - they are already linked to each other, we * just have to update the first and last. */ toPtr->lastPtr = objPtr; objPtr->internalRep.ptr = toPtr->firstObjPtr; /* NULL */ toPtr->firstObjPtr = fromFirstObjPtr; } /* *---------------------------------------------------------------------- * * PutObjs -- |
︙ | ︙ | |||
735 736 737 738 739 740 741 | fromPtr->numObjects = keep; firstPtr = fromPtr->firstObjPtr; if (keep == 0) { fromPtr->firstObjPtr = NULL; } else { do { lastPtr = firstPtr; | | | | | 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 | fromPtr->numObjects = keep; firstPtr = fromPtr->firstObjPtr; if (keep == 0) { fromPtr->firstObjPtr = NULL; } else { do { lastPtr = firstPtr; firstPtr = (Tcl_Obj *)firstPtr->internalRep.ptr; } while (keep-- > 1); lastPtr->internalRep.ptr = NULL; } /* * Move all objects as a block - they are already linked to each other, we * just have to update the first and last. */ Tcl_MutexLock(objLockPtr); fromPtr->lastPtr->internalRep.ptr = sharedPtr->firstObjPtr; sharedPtr->firstObjPtr = firstPtr; if (sharedPtr->numObjects == 0) { sharedPtr->lastPtr = fromPtr->lastPtr; } sharedPtr->numObjects += numMove; Tcl_MutexUnlock(objLockPtr); |
︙ | ︙ |
Changes to generic/tclVar.c.
︙ | ︙ | |||
231 232 233 234 235 236 237 | static Tcl_FreeInternalRepProc FreeParsedVarName; static Tcl_DupInternalRepProc DupParsedVarName; /* * Types of Tcl_Objs used to cache variable lookups. * * localVarName - INTERNALREP DEFINITION: | | | | | | | | | | | | | | 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 | static Tcl_FreeInternalRepProc FreeParsedVarName; static Tcl_DupInternalRepProc DupParsedVarName; /* * Types of Tcl_Objs used to cache variable lookups. * * localVarName - INTERNALREP DEFINITION: * ptr: pointer to name obj in varFramePtr->localCache * or NULL if it is this same obj * ptr2: index into locals table * * parsedVarName - INTERNALREP DEFINITION: * ptr: pointer to the array name Tcl_Obj, or NULL if it is a * scalar variable * ptr2: pointer to the element name string (owned by this * Tcl_Obj), or NULL if it is a scalar variable */ static const Tcl_ObjType localVarNameType = { "localVarName", FreeLocalVarName, DupLocalVarName, NULL, NULL, TCL_OBJTYPE_V0 }; #define LocalSetInternalRep(objPtr, index, namePtr) \ do { \ Tcl_ObjInternalRep ir; \ Tcl_Obj *ptr = (namePtr); \ if (ptr) {Tcl_IncrRefCount(ptr);} \ ir.ptr = ptr; \ ir.size2 = index; \ Tcl_StoreInternalRep((objPtr), &localVarNameType, &ir); \ } while (0) #define LocalGetInternalRep(objPtr, index, name) \ do { \ const Tcl_ObjInternalRep *irPtr; \ irPtr = TclFetchInternalRep((objPtr), &localVarNameType); \ (name) = irPtr ? (Tcl_Obj *)irPtr->ptr : NULL; \ (index) = irPtr ? irPtr->size2 : TCL_INDEX_NONE; \ } while (0) static const Tcl_ObjType parsedVarNameType = { "parsedVarName", FreeParsedVarName, DupParsedVarName, NULL, NULL, TCL_OBJTYPE_V0 }; #define ParsedSetInternalRep(objPtr, arrayPtr, elem) \ do { \ Tcl_ObjInternalRep ir; \ Tcl_Obj *ptr1 = (arrayPtr); \ Tcl_Obj *ptr2 = (elem); \ if (ptr1) {Tcl_IncrRefCount(ptr1);} \ if (ptr2) {Tcl_IncrRefCount(ptr2);} \ ir.ptr = ptr1; \ ir.ptr2 = ptr2; \ Tcl_StoreInternalRep((objPtr), &parsedVarNameType, &ir); \ } while (0) #define ParsedGetInternalRep(objPtr, parsed, array, elem) \ do { \ const Tcl_ObjInternalRep *irPtr; \ irPtr = TclFetchInternalRep((objPtr), &parsedVarNameType); \ (parsed) = (irPtr != NULL); \ (array) = irPtr ? (Tcl_Obj *)irPtr->ptr : NULL; \ (elem) = irPtr ? (Tcl_Obj *)irPtr->ptr2 : NULL; \ } while (0) Var * TclVarHashCreateVar( TclVarHashTable *tablePtr, const char *key, int *newPtr) |
︙ | ︙ | |||
5718 5719 5720 5721 5722 5723 5724 | *---------------------------------------------------------------------- */ /* * localVarName - * * INTERNALREP DEFINITION: | | | | 5718 5719 5720 5721 5722 5723 5724 5725 5726 5727 5728 5729 5730 5731 5732 5733 5734 | *---------------------------------------------------------------------- */ /* * localVarName - * * INTERNALREP DEFINITION: * ptr: pointer to name obj in varFramePtr->localCache * or NULL if it is this same obj * ptr2: index into locals table */ static void FreeLocalVarName( Tcl_Obj *objPtr) { Tcl_Size index; |
︙ | ︙ | |||
5757 5758 5759 5760 5761 5762 5763 | LocalSetInternalRep(dupPtr, index, namePtr); } /* * parsedVarName - * * INTERNALREP DEFINITION: | | | | 5757 5758 5759 5760 5761 5762 5763 5764 5765 5766 5767 5768 5769 5770 5771 5772 | LocalSetInternalRep(dupPtr, index, namePtr); } /* * parsedVarName - * * INTERNALREP DEFINITION: * ptr = pointer to the array name Tcl_Obj (NULL if scalar) * ptr2 = pointer to the element name string (owned by this * Tcl_Obj), or NULL if it is a scalar variable */ static void FreeParsedVarName( Tcl_Obj *objPtr) { |
︙ | ︙ |